﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using MobilePlugin.Core;
using System.IO;

namespace StartUp
{
    public partial class FrmStartUp : Form
    {
        private static string curDir = "";
        private PluginManager manager;
        public FrmStartUp()
        {
            InitializeComponent();
            curDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
            if (curDir.Substring(curDir.Length - 2, 1) != "\\")
            {
                curDir = curDir + "\\";
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            manager = PluginManager.GetInstance;
            string tmpFile = curDir + "PluginTemplate.xml";
            if (manager != null)
            {
                manager.LoadPlugins(tmpFile);
            }
            Dialog.FrmMain main = new StartUp.Dialog.FrmMain();
            main.Owner = this;
            main.ShowDialog();
            main.Dispose();
        }

        private void FrmStartUp_Closing(object sender, CancelEventArgs e)
        {
            manager.UnLoadPlugins();
        }
    }
}